import React, { Component } from 'react'
import BookList from './components/BookList'
import axios from "axios";

export default class App extends Component {
  state = {
    bookInfo: {}
  }
  render() {
    return (
      <div>
        <BookList render={() => (
          <h3 style={{ color: "skyblue" }}>{"男生必读"}</h3>
        )} bookInfo={this.state.bookInfo.boy} />
        <hr />
        <BookList render={() => (
          <h3 style={{ color: "pink" }}>{"女生必读"}</h3>
        )} bookInfo={this.state.bookInfo.girl} />
      </div>
    )
  }
  async axios (){
    const bookInfo = await axios.get('http://localhost:8080/book.json')
    console.log('node起的服务返回的数据',bookInfo.data);
    this.setState({
      bookInfo:bookInfo.data
    })
  }
  componentDidMount(){
    this.axios()
  }
}
